package gui.win.proj.rm;

import core.utils.Utils;
import gui.Segl1;
import gui.processor.Processor;
import gui.processor.Worker;
import gui.utils.Para;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class Buttons extends JPanel implements ActionListener{
    private JButton close, addProject;
    private RmP rmP;
    private Segl1 segL1;
   
    public Buttons(Segl1 L1_RpgsGui, RmP rmP){
        super(new BorderLayout());
        this.segL1 = L1_RpgsGui;
        this.rmP = rmP;
        this.add(Utils.getButton(close = new JButton("CANCEL"), 184, 22, new Color(102, 102, 102), new Color(178, 178, 178), this, "Cancel"), BorderLayout.WEST);
        this.add(Utils.getButton(addProject = new JButton("REMOVE"), 184, 22, new Color(102, 102, 102), new Color(178, 178, 178), this, "Remove Project"), BorderLayout.EAST);
    }

    public void actionPerformed(ActionEvent evt) {
        Object source = evt.getSource();
        if(source == close){rmP.dispose();}
        else if(source == addProject){
            Processor processor = new Processor(segL1);
            processor.setTask(Para.TASK_RM_PROJ);
            Worker sl = new Worker(processor);
            sl.execute();
            closeFrame();
        }
    }
    public void closeFrame(){rmP.closeFrame();}
}